﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HeresyManager.Comunication;

public partial class Controls_InputNumber : System.Web.UI.UserControl
{
    private RoleDice roleDice;

    public RoleDice RoleDice
    {
        get { return roleDice; }
        set { roleDice = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (RoleDice != null)
        {
            Description.Text = RoleDice.Purposer;
            RandomButton.Text = "Role " + RoleDice.Dice.ToString();
            //RangeValidator1.MinimumValue = RoleDice.Dice.MinValue.ToString();
            //RangeValidator1.MaximumValue = RoleDice.Dice.MaxValue.ToString();
            Input.Text = RoleDice.Dice.Roll().ToString();
            Input_TextChanged(this, EventArgs.Empty);
        }
    }
    protected void RandomButton_Click(object sender, EventArgs e)
    {
        Input.Text = RoleDice.Dice.Roll().ToString();
        Input_TextChanged(this, EventArgs.Empty);
    }
    protected void Input_TextChanged(object sender, EventArgs e)
    {
        try
        {
            RoleDice.Value = int.Parse(Input.Text);

        }
        catch (FormatException)
        {
            RoleDice.Value = -1;
        }
    }
}